package com.opo5.logisticsmanagement.config;

import com.opo5.logisticsmanagement.service.AutoTaskService;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @Title: AutoTaskSwitch
 * @Author: lixin
 * @Date: 2022/07/11/13:20
 * @Description: 运行启动自动任务
 */
@Component
public class AutoTaskSwitch implements CommandLineRunner, DisposableBean {

    @Autowired
    private AutoTaskService autoTaskService;

    @Override
    public void run(String... args) throws Exception {
        autoTaskService.executeAll();
    }

    @Override
    public void destroy() throws Exception {
        autoTaskService.closeAll();
    }
}
